﻿<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="UTF-8"%>

<%@include file="top.jsp"%>
<%@include file="left.jsp"%>
    <div id="content" class="align-right"> 
				<div id="content-ads">
					<img src="images/ads_2.png" width="800" height="90" />
				</div>
				<h2>情绪地图</h2>
				<p>								 
			    </p>
				<div id="main-content">
					<table>
							<thead>
								<tr>
								   <th>地点图片</th>
                                   <th>地点名称</th>
								   <th>情绪描述</th>
								   <th>详细地址</th>
								   <th>联系电话</th>
								   <th>营业时间</th>
								</tr>
								
							</thead>
						 						 
							<tbody>
		<%
		    String emotionId = request.getParameter("emotionid");
		    int emotionid=Integer.parseInt(emotionId);
		    
			int pageNum = 1;	//当前第1页
			int pageSize = 4; //每页15条记录
			int recordCount;   //数据库的中的条数
			int pageCount;
			String strPageNum = request.getParameter("pagenum");
			if(null == strPageNum || "".equals(strPageNum)){
				
			}else{
				pageNum = Integer.parseInt(strPageNum);
			}
			
			Connection dbn = db.getConnection();
			//Statement stmt = dbc.createStatement();
			String sqln = "SELECT d.desid,d.name,e.emotionname,d.address,d.telephone,b.timename FROM desination AS d, emotion AS e, bustime AS b WHERE d.emotionid=e.emotionid AND d.timeid=b.timeid AND (d.emotionid=?)";
			PreparedStatement pstmt = dbn.prepareStatement(sqln, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
			pstmt.setInt(1, emotionid);
			ResultSet rsn = pstmt.executeQuery();
			rsn.last();
			recordCount = rsn.getRow();
			
			if(recordCount % pageSize == 0){
				pageCount = recordCount / pageSize;
			}else{
				pageCount = recordCount / pageSize + 1;
			}
			rsn.absolute((pageNum-1)*pageSize);
			int i = 0;
			while(rsn.next() && i < pageSize){	
	   %>
								<tr class="alt-row">
									<td><img src="images/upload/item_1.png"/></td>
									<td><a title="title" href="dest_info.jsp?desid=<%=rsn.getInt("desid")%>"><%=rsn.getString("name") %></a></td>
									<td><%=rsn.getString("emotionname") %></td>
									<td><%=rsn.getString("address") %></td>
									<td><%=rsn.getString("telephone") %></td>
									<td><%=rsn.getString("timename") %></td>
								</tr>
			<%
				i++;
				}
                rsn.close();
				dbn.close();
			%>
							</tbody>
													
														<tfoot>
								<tr>
									<td colspan="6">
										<div class="pagination">
											<%if(pageNum != 1){ %>
											<a href="so_emotion_map.jsp" title="首页">&laquo; 首页</a>
											<a href="so_emotion_map.jsp?pagenum=<%= pageNum-1 %>" title="前一页">&laquo; 前一页</a>
											<%} %>
											当前<%= pageNum%>页/共<%= pageCount%>页
											<%if(pageNum != pageCount){ %>
											<a href="so_emotion_map.jsp?pagenum=<%= pageNum+1 %>" title="后一页">后一页 &raquo;</a>
											<a href="so_emotion_map.jsp?pagenum=<%= pageCount %>" title="末页">末页 &raquo;</a>
											<%} %>
										</div> <!-- End .pagination -->
										<div class="clear"></div>
									</td>
								</tr>
							</tfoot>
						</table>
					</div>
			</div>


<!-- 特殊 选中样式 -->
<script type="text/javascript">
	
	$(document).ready(function(){
		
		/*选中，如下*/
		$('#li-map').addClass('on');
		
	});
</script>

<%@include file="bottom.jsp"%>
